home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: Mar 14, 1997
- //
- //
- // Description:
- // This script is defines the option box for the revolve menu item.
- //
- // Input Arguments:
- // int showOptionBox true - show the option box dialog
- // false - just execute the revolve operation
- //
- // Return Value:
- // None.
- //
-
- proc
- setOptionVars (int $forceFactorySettings)
- {
- revolveSetOptionVars( $forceFactorySettings );
- }
-
- global proc revolveSetup( string $parent,
- int $forceFactorySettings,
- string $goToTool )
- {
- // Retrieve the option settings
- //
- setOptionVars ($forceFactorySettings);
- revolveToolSetup( $forceFactorySettings, $goToTool );
-
- setParent $parent;
-
- // Query all of the optionVar's
- //
- int $usePresetAxis = `optionVar -q revolveUsePresetAxis` + 1;
- float $axisX, $axisY, $axisZ;
- switch( $usePresetAxis ) {
- case 1: $axisX = 1; $axisY = 0; $axisZ = 0; break;
- case 2: $axisX = 0; $axisY = 1; $axisZ = 0; break;
- case 3: $axisX = 0; $axisY = 0; $axisZ = 1; break;
- case 4:
- $axisX = `optionVar -q revolveAxisX`;
- $axisY = `optionVar -q revolveAxisY`;
- $axisZ = `optionVar -q revolveAxisZ`;
- break;
- }
- int $useObjectPivot = `optionVar -q revolveUseLocalPivot`;
- float $pivotX, $pivotY, $pivotZ;
- if( $useObjectPivot ) {
- $pivotX = 0;
- $pivotY = 0;
- $pivotZ = 0;
- }
- else {
- $pivotX = `optionVar -q revolvePivotX`;
- $pivotY = `optionVar -q revolvePivotY`;
- $pivotZ = `optionVar -q revolvePivotZ`;
- }
- float $startSweep = `optionVar -q revolveStartSweepAngle`;
- float $endSweep = `optionVar -q revolveEndSweepAngle`;
- int $degree = `optionVar -q revolveSurfaceDegree`;
- switch( $degree ) {
- case 1: $degree = 1; break; // used below for degreeRadioButtonGrp
- case 3: $degree = 2; break; // used below for degreeRadioButtonGrp
- }
- int $useTol = `optionVar -q revolveUseTolerance`;
- int $useGlobalTol = `optionVar -q revolveUseGlobalTol`;
- float $tol = `optionVar -q revolveTolerance`;
-
- int $numSegments = `optionVar -q revolveNumberOfSegments`;
- int $partialCrvRange = `optionVar -q revolveCurveRangePartial` + 1;
- int $outputPolys = `optionVar -q revolveOutputPolygons`;
- if( ! `isTrue "SurfaceUIExists"` ) $outputPolys = 1;
-
-
- // Set the controls
- //
- radioButtonGrp -edit -select $usePresetAxis presetAxisRadioGroup;
- radioButtonGrp -edit -select (2 - $useObjectPivot) pivotPointRadioGroup;
- floatFieldGrp -edit -v1 $axisX axisFloatFieldGrp;
- floatFieldGrp -edit -v2 $axisY axisFloatFieldGrp;
- floatFieldGrp -edit -v3 $axisZ axisFloatFieldGrp;
- floatFieldGrp -edit -v1 $pivotX pivotFloatFieldGrp;
- floatFieldGrp -edit -v2 $pivotY pivotFloatFieldGrp;
- floatFieldGrp -edit -v3 $pivotZ pivotFloatFieldGrp;
- floatSliderGrp -edit -value $startSweep startSweepFloatSliderGrp;
- floatSliderGrp -edit -value $endSweep endSweepFloatSliderGrp;
- radioButtonGrp -edit -select $degree degreeRadioButtonGrp;
- intSliderGrp -edit -value $numSegments segmentsIntSliderGrp;
-
- if( $useTol ) {
- if( $useGlobalTol ) {
- radioButtonGrp -edit -select 3 useTolerance;
- }
- else {
- radioButtonGrp -edit -select 2 useTolerance;
- }
- }
- else {
- radioButtonGrp -edit -select 1 useTolerance;
- }
- floatSliderGrp -edit -value $tol toleranceFloatFieldGrp;
-
- radioButtonGrp -edit -select $partialCrvRange curveRangeRadioButtonGrp;
- if( `isTrue "SurfaceUIExists"` ) {
- if( (3 == $outputPolys) && ! `isTrue "SubdivUIExists"` ) {
- $outputPolys = 2;
- }
- radioButtonGrp -edit -select ($outputPolys+1) outputPolyRadioButtonGrp;
- }
-
-
- // Disable and enable some sliders depending on other values
- //
- if( $usePresetAxis == 4 )
- floatFieldGrp -e -enable 1 axisFloatFieldGrp;
- else
- floatFieldGrp -e -enable 0 axisFloatFieldGrp;
- if( $useObjectPivot == 0 )
- floatFieldGrp -e -enable 1 pivotFloatFieldGrp;
- else
- floatFieldGrp -e -enable 0 pivotFloatFieldGrp;
-
- if( $useTol ) {
- tabLayout -e -selectTab useToleranceSlider tlTolerance;
- if( $useGlobalTol ) {
- tabLayout -e -selectTab tolGlobal tlUseGlobal;
- }
- else {
- tabLayout -e -selectTab tolLocal tlUseGlobal;
- }
- }
- else {
- tabLayout -e -selectTab useToleranceNoSlider tlTolerance;
- }
-
- switch( $outputPolys ) {
- case 0:
- default:
- tabLayout -e -st polyOptionsNo polyOptions;
- break;
- case 1:
- tabLayout -e -st polyOptionsOK polyOptions;
- break;
- case 2:
- tabLayout -e -st polyOptionsSubdiv polyOptions;
- break;
- case 3:
- tabLayout -e -st polyOptionsBezier polyOptions;
- break;
- }
-
- if( "" != $goToTool ) {
- checkBoxGrp -e -v1 `scriptCtx -q -euc $goToTool`
- scriptToolExtraWidget;
- checkBoxGrp -e -v2 `scriptCtx -q -lac $goToTool`
- scriptToolExtraWidget;
- }
-
- nurbsToPolySetup( $parent, $forceFactorySettings );
- nurbsToSubdivSetup( $parent, $forceFactorySettings );
- }
-
- global proc revolveCallback( string $parent, int $doIt, string $goToTool )
- {
- if( "" != $goToTool ) {
- optionVar -iv revolveEuc `scriptCtx -q -euc $goToTool`;
- optionVar -iv revolveLac `scriptCtx -q -lac $goToTool`;
- }
- setParent $parent;
-
- // Get all the values from the controls
- //
- int $usePresetAxis = `radioButtonGrp -q -select presetAxisRadioGroup` - 1;
- int $useObjectPivot = 2 - `radioButtonGrp -q -select pivotPointRadioGroup`;
- float $axisX = `floatFieldGrp -q -v1 axisFloatFieldGrp`;
- float $axisY = `floatFieldGrp -q -v2 axisFloatFieldGrp`;
- float $axisZ = `floatFieldGrp -q -v3 axisFloatFieldGrp`;
- float $pivotX = `floatFieldGrp -q -v1 pivotFloatFieldGrp`;
- float $pivotY = `floatFieldGrp -q -v2 pivotFloatFieldGrp`;
- float $pivotZ = `floatFieldGrp -q -v3 pivotFloatFieldGrp`;
- float $startSw = `floatSliderGrp -q -value startSweepFloatSliderGrp`;
- float $endSw = `floatSliderGrp -q -value endSweepFloatSliderGrp`;
- int $degree = `radioButtonGrp -q -select degreeRadioButtonGrp`;
- if( $degree == 1 ) $degree = 1; else $degree = 3;
- int $segments = `intSliderGrp -q -value segmentsIntSliderGrp`;
-
- int $valUse = `radioButtonGrp -q -select useTolerance`;
- switch( $valUse ) {
- case 1:
- optionVar -intValue revolveUseTolerance false;
- break;
- case 2:
- optionVar -intValue revolveUseTolerance true;
- optionVar -intValue revolveUseGlobalTol false;
- break;
- case 3:
- default:
- optionVar -intValue revolveUseTolerance true;
- optionVar -intValue revolveUseGlobalTol true;
- break;
- }
-
-
- float $tol = `floatSliderGrp -q -value toleranceFloatFieldGrp`;
- int $useCrvRange = `radioButtonGrp -q -select curveRangeRadioButtonGrp` -1;
- if( `isTrue "SurfaceUIExists"` ) {
- int $outputPolys;
- $outputPolys = `radioButtonGrp -q -select outputPolyRadioButtonGrp`;
- if( (3 == $outputPolys) && ! `isTrue "SubdivUIExists"` ) {
- $outputPolys = 4;
- }
- optionVar -intValue revolveOutputPolygons ($outputPolys-1);
- }
-
- // Set all the corresponding option var's
- //
- optionVar -intValue revolveUsePresetAxis $usePresetAxis;
- optionVar -intValue revolveUseLocalPivot $useObjectPivot;
- if( $usePresetAxis == 3 ) {
- optionVar -floatValue revolveAxisX $axisX;
- optionVar -floatValue revolveAxisY $axisY;
- optionVar -floatValue revolveAxisZ $axisZ;
- }
- if( !$useObjectPivot ) {
- optionVar -floatValue revolvePivotX $pivotX;
- optionVar -floatValue revolvePivotY $pivotY;
- optionVar -floatValue revolvePivotZ $pivotZ;
- }
- optionVar -floatValue revolveStartSweepAngle $startSw;
- optionVar -floatValue revolveEndSweepAngle $endSw;
- optionVar -intValue revolveSurfaceDegree $degree;
- optionVar -intValue revolveNumberOfSegments $segments;
- optionVar -floatValue revolveTolerance $tol;
- optionVar -intValue revolveCurveRangePartial $useCrvRange;
-
- nurbsToPolyCallback( $parent, 0 );
- nurbsToSubdivCallback( $parent, 0 );
-
- if( 1 == $doIt ) {
- performRevolve( 0, $goToTool );
- string $tmpCmd = "performRevolve( 0, \"" + $goToTool + "\")";
- addToRecentCommandQueue $tmpCmd "Revolve";
- }
- else if( $doIt ) {
- setToolTo $goToTool;
- }
- }
-
- proc revolveOptions( int $inTheTool, string $goToTool )
- {
- // Name of the command for this option box.
- //
- string $commandName = "revolve";
-
- // Build the option box actions.
- //
- string $callback = ($commandName + "Callback");
- string $setup = ($commandName + "Setup");
-
- global string $gOptionBoxActionToolItem;
- $gOptionBoxActionToolItem = "modelWithToolRevolve";
- global string $gOptionBoxActionToolItemCB;
- $gOptionBoxActionToolItemCB = "revolveToolScript 3";
-
- // Step 1: Get the option box.
- // ============================
- string $layout = getOptionBox();
- setParent $layout;
-
- // Step 2: Pass the command name to the option box.
- // =================================================
- setOptionBoxCommandName($commandName);
-
- // Step 3: Activate the default UI template.
- // ==========================================
- setUITemplate -pushTemplate DefaultTemplate;
-
- // Step 4: Create option box contents.
- // ===================================
-
- // Turn on the wait cursor.
- //
- waitCursor -state 1;
-
- tabLayout -scr true -tv false;
-
- string $parent = `columnLayout -adjustableColumn 1`;
-
- radioButtonGrp
- -numberOfRadioButtons 4
- -label "Axis Preset"
- -label1 "X"
- -label2 "Y"
- -label3 "Z"
- -label4 "Free"
- presetAxisRadioGroup;
- floatFieldGrp -l "Axis" -nf 3 axisFloatFieldGrp;
-
- radioButtonGrp
- -numberOfRadioButtons 2
- -label "Pivot"
- -label1 "Object"
- -label2 "Preset"
- pivotPointRadioGroup;
- floatFieldGrp -l "Pivot Point" -nf 3 pivotFloatFieldGrp;
-
- separator;
-
- radioButtonGrp
- -numberOfRadioButtons 2
- -label "Surface Degree"
- -label1 "Linear"
- -label2 "Cubic"
- degreeRadioButtonGrp;
-
- floatSliderGrp -label "Start Sweep Angle"
- -min 0 -max 360.0 -field on startSweepFloatSliderGrp;
- floatSliderGrp -label "End Sweep Angle"
- -min 0 -max 360.0 -field on endSweepFloatSliderGrp;
-
- radioButtonGrp -nrb 3 -l "Use Tolerance"
- -l1 "None" -l2 "Local" -l3 "Global"
- useTolerance;
- tabLayout -tabsVisible false tlTolerance;
- columnLayout useToleranceNoSlider;
- intSliderGrp -label "Segments"
- -min 0 -field on segmentsIntSliderGrp;
- setParent ..;
- columnLayout useToleranceSlider;
- tabLayout -tabsVisible false tlUseGlobal;
- columnLayout tolLocal;
- floatSliderGrp -label "Tolerance"
- -min 0.001 -max 1.0 -fmn 0.00001 -fmx 1000.0
- toleranceFloatFieldGrp;
- setParent ..;
- columnLayout tolGlobal;
- setParent ..;
- setParent ..;
- setParent ..;
- setParent ..;
-
- separator;
-
- radioButtonGrp -numberOfRadioButtons 2
- -label "Curve Range"
- -label1 "Complete"
- -label2 "Partial"
- curveRangeRadioButtonGrp;
-
- if( `isTrue "SubdivUIExists"` ) {
- radioButtonGrp -nrb 4
- -label "Output Geometry"
- -label1 "Nurbs"
- -label2 "Polygons"
- -label3 "Subdiv"
- -label4 "Bezier"
- -cc1 "tabLayout -e -st polyOptionsNo polyOptions"
- -cc2 "tabLayout -e -st polyOptionsOK polyOptions"
- -cc3 "tabLayout -e -st polyOptionsSubdiv polyOptions"
- -cc4 "tabLayout -e -st polyOptionsBezier polyOptions"
- outputPolyRadioButtonGrp;
- }
- else if( `isTrue "SurfaceUIExists"` ) {
- radioButtonGrp -nrb 3
- -label "Output Geometry"
- -label1 "Nurbs"
- -label2 "Polygons"
- -label3 "Bezier"
- -cc1 "tabLayout -e -st polyOptionsNo polyOptions"
- -cc2 "tabLayout -e -st polyOptionsOK polyOptions"
- -cc3 "tabLayout -e -st polyOptionsBezier polyOptions"
- outputPolyRadioButtonGrp;
- }
-
- // Set the Axis float field grp to display only when Axis Preset is Free
- //
- string $enable = "floatFieldGrp -e -en 1 axisFloatFieldGrp;" +
- "floatFieldGrp -e " +
- "-value1 `optionVar -q revolveAxisX` " +
- "-value2 `optionVar -q revolveAxisY` " +
- "-value3 `optionVar -q revolveAxisZ` axisFloatFieldGrp; ";
- string $disable = "floatFieldGrp -e -en 0 axisFloatFieldGrp;";
- radioButtonGrp -edit
- -cc1 ($disable +
- "floatFieldGrp -e -value 1.0 0.0 0.0 0.0 axisFloatFieldGrp;")
- -cc2 ($disable +
- "floatFieldGrp -e -value 0.0 1.0 0.0 0.0 axisFloatFieldGrp;")
- -cc3 ($disable +
- "floatFieldGrp -e -value 0.0 0.0 1.0 0.0 axisFloatFieldGrp;")
- -cc4 $enable
- presetAxisRadioGroup;
-
- // Set the Pivot float field grp to display only when Pivot is Global
- //
- string $enableP = "floatFieldGrp -e -en 1 pivotFloatFieldGrp;" +
- "floatFieldGrp -e " +
- "-value1 `optionVar -q revolvePivotX` " +
- "-value2 `optionVar -q revolvePivotY` " +
- "-value3 `optionVar -q revolvePivotZ` pivotFloatFieldGrp;";
- string $disableP = "floatFieldGrp -e -en 0 pivotFloatFieldGrp;";
- radioButtonGrp -edit -cc1 $disableP -cc2 $enableP pivotPointRadioGroup;
-
- // Set the "Use Tolerance" checkbox so that if the checkbox is on,
- // then the tolerance slider is visible.
- //
- radioButtonGrp -edit
- -on1 ( "tabLayout -e -selectTab useToleranceNoSlider tlTolerance;" )
- -on2 ( "tabLayout -e -selectTab useToleranceSlider tlTolerance;" +
- "tabLayout -e -selectTab tolLocal tlUseGlobal;" )
- -on3 ( "tabLayout -e -selectTab useToleranceSlider tlTolerance;" +
- "tabLayout -e -selectTab tolGlobal tlUseGlobal;" )
- useTolerance;
-
-
- separator;
-
- tabLayout -tabsVisible false polyOptions;
- string $par = `columnLayout polyOptionsOK`;
- nurbsToPolyAddOptions $par;
- setParent ..;
- columnLayout polyOptionsNo;
- setParent ..;
- columnLayout polyOptionsSubdiv;
- nurbsToSubdivAddOptions $par;
- setParent ..;
- columnLayout polyOptionsBezier;
- setParent ..;
- setParent ..;
-
- if( $inTheTool ) {
- separator;
- checkBoxGrp -ncb 2 -l "Tool Behavior"
- -l1 "Exit on Completion"
- -v1 off
- -on1 ("scriptCtx -e -euc true " + $goToTool)
- -of1 ("scriptCtx -e -euc false " + $goToTool)
-
- -l2 "Auto Completion"
- -v2 on
- -on2 ("scriptCtx -e -lac true " + $goToTool)
- -of2 ("scriptCtx -e -lac false " + $goToTool)
- scriptToolExtraWidget;
- }
-
- // Turn off the wait cursor.
- //
- waitCursor -state 0;
-
- // Step 5: Deactivate the default UI template.
- // ===========================================
- //
- setUITemplate -popTemplate;
-
- // Step 6: Customize the buttons.
- // ==============================
-
- // 'Apply' button.
- //
- string $applyBtn = getOptionBoxApplyBtn();
- if( $inTheTool ) {
- button -edit -l "Revolve Tool"
- -command ($callback + " " + $parent + " 3 \"" + $goToTool + "\"")
- $applyBtn;
- }
- else {
- button -edit -l "Revolve"
- -command ($callback + " " + $parent + " 1 \"" + $goToTool + "\"")
- $applyBtn;
- }
-
- // 'Save' button.
- //
- string $saveBtn = getOptionBoxSaveBtn();
- button -edit
- -command ($callback + " " + $parent + " 0 \"" +
- $goToTool + "\"; hideOptionBox")
- $saveBtn;
-
- // 'Reset' button.
- //
- string $resetBtn = getOptionBoxResetBtn();
- button -edit
- -command ($setup + " " + $parent + " 1 \"" + $goToTool + "\"")
- $resetBtn;
-
- // Step 7: Set the option box title.
- // =================================
- //
- if( $inTheTool ) {
- setOptionBoxTitle("Revolve Tool Options");
- }
- else {
- setOptionBoxTitle("Revolve Options");
- }
-
- // Step 8: Customize the 'Help' menu item text.
- // ============================================
- //
- setOptionBoxHelpTag( "Revolve" );
-
- // Step 9: Set the current values of the option box.
- // =================================================
- //
- eval ($setup + " " + $parent + " 0 \"" + $goToTool + "\"");
-
- // Step 10: Show the option box.
- // =============================
- //
- showOptionBox();
- }
-
- //
- // Procedure Name:
- // revolveHelp
- //
- // Description:
- // Return a short description about this command.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // string.
- //
-
- proc string revolveHelp()
- {
- return
- " Command: Revolve - create surface from a curve\n" +
- "Selection: curve, curve on surface, surface isoparm";
- }
-
- proc string assembleCmd()
- {
- string $cmd;
-
- setOptionVars( false );
-
- int $usePresetAxis = `optionVar -q revolveUsePresetAxis`;
- float $axisX, $axisY, $axisZ;
- switch( $usePresetAxis ) {
- case 0: $axisX = 1; $axisY = 0; $axisZ = 0; break;
- case 1: $axisX = 0; $axisY = 1; $axisZ = 0; break;
- case 2: $axisX = 0; $axisY = 0; $axisZ = 1; break;
- case 3:
- $axisX = `optionVar -q revolveAxisX`;
- $axisY = `optionVar -q revolveAxisY`;
- $axisZ = `optionVar -q revolveAxisZ`;
- break;
- }
- int $useObjectPivot = `optionVar -q revolveUseLocalPivot`;
- float $pivotX, $pivotY, $pivotZ;
- switch( $useObjectPivot ) {
- case 1: $pivotX = 0; $pivotY = 0; $pivotZ = 0; break;
- case 0:
- $pivotX = `optionVar -q revolvePivotX`;
- $pivotY = `optionVar -q revolvePivotY`;
- $pivotZ = `optionVar -q revolvePivotZ`;
- break;
- }
- float $startSweep = `optionVar -q revolveStartSweepAngle`;
- float $endSweep = `optionVar -q revolveEndSweepAngle`;
- int $degree = `optionVar -q revolveSurfaceDegree`;
- int $useTol = `optionVar -q revolveUseTolerance`;
- float $tol = `optionVar -q revolveTolerance`;
- if( `optionVar -q revolveUseGlobalTol` ) {
- $tol = `optionVar -q positionalTolerance`;
- }
- int $numSegments = `optionVar -q revolveNumberOfSegments`;
- int $partialCrvRange = `optionVar -q revolveCurveRangePartial`;
- int $outputPolys = `optionVar -q revolveOutputPolygons`;
- if( ! `isTrue "SurfaceUIExists"` ) $outputPolys = 1;
- int $doHistory = `constructionHistory -q -tgl`;
-
- // Piece together the revolve command
- //
- string $cmd;
- $cmd = ( "revolvePreset " +
- $doHistory + " " + $outputPolys + " " + $partialCrvRange + " " +
- $startSweep + " " + $endSweep + " " + $useTol + " " + $tol + " " +
- $degree + " " + $numSegments + " " + $useObjectPivot + " " +
- $axisX + " " + $axisY + " " + $axisZ + " " +
- $pivotX + " " + $pivotY + " " + $pivotZ );
- return $cmd;
- }
-
- // The action variable means
- // 0 - Execute the command.
- // 1 - Show the option box dialog.
- // 2 - Return the command.
- // 3 - Show the tool option box dialog.
-
- global proc string performRevolve( int $action, string $goToTool )
- {
- int $inTheTool = false;
- if( 3 == $action ) {
- $action = 1;
- $inTheTool = true;
- }
-
- string $cmd = "";
- switch ($action) {
- case 0:
- setOptionVars (false);
- $cmd = `assembleCmd`;
- eval($cmd);
- break;
- case 1:
- revolveOptions( $inTheTool, $goToTool );
- break;
- case 2:
- default:
- setOptionVars (false);
- $cmd = `assembleCmd`;
- break;
- }
- return $cmd;
- }
-